package com.mtsmda.chapter7.equalsAndHashCode;

public class FootballClub {

	private String clubName;
	private String theBestPlayer;

	public FootballClub() {

	}

	public String getClubName() {
		return clubName;
	}

	public void setClubName(String clubName) {
		this.clubName = clubName;
	}

	public String getTheBestPlayer() {
		return theBestPlayer;
	}

	public void setTheBestPlayer(String theBestPlayer) {
		this.theBestPlayer = theBestPlayer;
	}

	/**
	 * {@inheritDoc}
	 * */
	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		if (obj instanceof FootballClub
				&& ((FootballClub) obj).getClubName() != null
				&& this.getClubName() != null
				&& ((FootballClub) obj).getClubName()
						.equals(this.getClubName())
				&& ((FootballClub) obj).getTheBestPlayer() != null
				&& this.getTheBestPlayer() != null
				&& ((FootballClub) obj).getTheBestPlayer().equals(
						this.getTheBestPlayer())) {
			return true;
		}
		return false;
	}

	@Override
	public int hashCode() {
		int hashCode = 9026;
		if (this.getClubName() != null && !this.getClubName().isEmpty()
				&& this.getTheBestPlayer() != null
				&& !this.getTheBestPlayer().isEmpty()) {
			hashCode = this.getClubName().length() * hashCode
					* this.getTheBestPlayer().length() * hashCode;
		}
		return hashCode;
	}
}